package 算法;

public class Demo {
	static class Count {
		Integer number0;
		Integer number1;

		public Count(Integer number0, Integer number1) {
			this.number0 = number0;
			this.number1 = number1;
		}
	}

	public static void main(String[] args) {
		String[] strs = new String[]{"10", "0001", "111001", "1", "0"};
		int m = 5;
		int n = 3;
		//findMaxForm(strs, m, n);
		findMax(strs, m, n);

	}

	/**
	 * @param strs
	 * @param m
	 * @param n
	 * @return
	 */
	public static int findMax(String[] strs, int m, int n) {
		// 背包容量
		/**
		 * m = 3
		 * n =2
		 * m/n 0 1 2
		 * 0   0 0 0
		 * 1   0 0 0
		 * 2   0 0 0
		 * 3   0 0 0
		 *
		 */
		int[][] dp = new int[m + 1][n + 1];
		for (String s : strs) {
			int[] count = countNumber0(s);
			System.out.println(count);
		}
		return 0;
	}

	/**
	 * 统计数字0
	 *
	 * @param s
	 * @return
	 */
	private static int[] countNumber0(String s) {
		int[] count = new int[2];
		for (int i = 0; i < s.length(); i++) {
			int i1 = s.charAt(i) - '0';

			int i3 = '0' - s.charAt(i);
			System.out.println((char)('0'));
			System.out.println(i1);

			System.out.println(i3);

			count[i1]++;
		}
		return count;
	}

	/*
	dp(i, j) = max(1 + dp(i - cost_zero[k], j - cost_one[k]))
			if i >= cost_zero[k] and j >= cost_one[k]
	*/
	public static int findMaxForm(String[] strs, int m, int n) {
		Count[] countStrs = new Count[strs.length];
		for (int i = 0; i < strs.length; i++) {
			String[] str = strs[i].split("");
			Integer number0Size = 0;
			Integer number1Size = 0;
			for (int j = 0; j < str.length; j++) {
				String charItem = str[j];
				if ("0".equals(charItem)) {
					number0Size += 1;
				} else if ("1".equals(charItem)) {
					number1Size += 1;
				}
			}
			countStrs[i] = new Count(number0Size, number1Size);
		}
		System.out.println(countStrs.toString());
		return 0;
	}

}
